package org.dc.service;

import android.content.Context;

/**
 * @user: Vladimir Chernishov
 * @date: 2/29/12
 * @time: 6:05 PM
 */
public class PersistenceManager {

//    private static final PersistenceManager instance = new PersistenceManager();
    private static ShiftDao shiftDao;
    private static WorkDayDao workDayDao;
    private static VisitDao visitDao;

//    public static PersistenceManager getManager(){
//        return instance;
//    }

    public static ShiftDao getShiftDao(Context context) {
        if(shiftDao == null){
            shiftDao = new ShiftDaoImpl(context);
        }
        return shiftDao;
    }

    public static WorkDayDao getWorkDayDao(Context context) {
        if(workDayDao == null){
            workDayDao = new WorkDayDaoImpl(context);
        }
        return workDayDao;
    }

    public static VisitDao getVisitDao(Context context) {
        if(visitDao == null){
            visitDao = new VisitDaoImpl(context);
        }
        return visitDao;
    }

    public static void close(){
        if(shiftDao != null){
            shiftDao.close();
        }
        if(workDayDao != null){
            workDayDao.close();
        }
        if(visitDao != null){
            visitDao.close();
        }
    }

}
